<template>
  <div v-if="data.length > 0" style="width: 100%; height: 100%">
    <div v-for="item in items" :key="item[0]" style="margin-bottom: 25px">
      <sec-popover
        placement="top"
        width="150"
        trigger="hover"
        :close-delay="0"
        popper-class="progress-popper"
      >
        <div style="display: flex; align-items: baseline">
          <div class="tooltip"></div>
          <div>
            <span
              style="
                display: inline-block;
                margin-right: 16px;
                color: #5c5c5c;
                font-size: 12px;
              "
              >{{ item[0] }}</span
            >
            <span style="font-size: 12px">{{ item[1].count }}</span>
          </div>
        </div>
        <div slot="reference" style="display: flex">
          <div style="flex: 0 0 88px; width">
            <span class="label">{{ item[0] }}</span>
          </div>
          <div style="flex: 1 1 auto">
            <sec-progress :percentage="+item[1].value"></sec-progress>
          </div>
        </div>
      </sec-popover>
    </div>
  </div>
  <nodata-box v-else />
</template>

<script>
export default {
  name: 'ProgressChart',
  props: {
    data: {
      type: Array,
      default: () => {
        return []
      },
      required: true
    },
    labels: {
      type: Array,
      default: () => {
        return []
      },
      required: true
    }
  },
  computed: {
    items: function () {
      return this.data.map((item, index) => {
        return [this.labels[index], item]
      })
    }
  },
  mounted() {},
  methods: {}
}
</script>
<style scoped lang="scss">
.label {
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #595959;
  line-height: 18px;
  display: block;
  width: 72px;
  text-align: right;
}
.el-progress {
  ::v-deep {
    display: flex;
    align-items: center;
    .el-progress__text {
      font-size: 12px !important;
      font-family: ArialMT;
      color: #262626;
      line-height: 18px;
      margin-left: 13px;
    }
    .el-progress-bar {
      .el-progress-bar__outer {
        background-color: #f0f0f0;
      }
    }
  }
}
.tooltip {
  width: 8px;
  height: 8px;
  background: #3366ff;
  border-radius: 2px;
  margin-right: 8px;
}
::v-deep {
  .popper {
    width: 148px;
    height: 33px;
    background: #ffffff;
    box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.16);
    border-radius: 2px;
    border: 1px solid #d9d9d9;
  }
}
</style>
<style lang="scss">
.progress-popper {
  height: 33px;
  display: flex;
  align-items: center;
  background: #ffffff;
  box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.16);
  border-radius: 2px;
  border: 1px solid #d9d9d9;
}
</style>
